package corej.prj.mogu;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class Gene {

    public static int getGeneSum(int num) {
        int i;
        int j;
        int sum = 0;
        Set col = new HashSet();
        for (i = 2; i <= num; i++) {
            for (j = (num - 1); j > 0; j--)
                if (getChen(i, j) == num) {
                    col.add(getAdd(i, j));
                }
        }
        Iterator it = col.iterator();
        while (it.hasNext()) {
            Integer in = (Integer) it.next();
            sum += in.intValue();
        }
        return sum;
    }

    public static int getChen(int i, int j) {
        return i * j;
    }

    public static int getAdd(int i, int j) {
        return i + j;
    }
    /*
      * int m; int n; int mn = 0; int sum = 0;
      *
      * for (n = i - 1; n >=2; n--) { for (m = 2; m <
      * (int)java.lang.Math.sqrt(i); m++) { if (i == m * n) { mn = m + n;
      * System.out.print("m="+m+",n="+n+",mn="+mn+"."); }
      *  } System.out.println(sum = sum + mn); }
      *
      * return sum;
      *
      */
}
